#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int long long
const int inf = 0x3f3f3f3f;

void solve()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt0 = 0, cnt1 = 0;
    for (auto c : s)
    {
        if (c == '0') cnt0++;
        else cnt1++;
    }
    int count = 0;
    for (int i = 0; i < n - 1; i++)
    {
        if (s[i] == '0') cnt0--;
        else cnt1--;
        int cur0 = cnt0, cur1 = cnt1;
        for (int j = n - 1; j > i; j--)
        {
            if (cur0 % 2 == 0 && cur1 % 2 == 0)
            {
                count++;
                break;
            }
            if (s[j] == '0') cur0--;
            else cur1--;
        }
    }
    cout << ((double)count / n);
}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int _ = 1;
    //cin >> _;
    while (_--)
    {
        solve();
    }
    return 0;
}